<template>
	<view>
		
		<match-media :min-width="768">
		<el-affix :offset="0.1">
			  <el-menu
			    :default-active="activeIndex"
			    class="el-menu-demo"
			    mode="horizontal"
			    :ellipsis="false"
				active-text-color="#ea6101"
			    @select="handleSelect"
			  >
			    <el-menu-item index="0">
			      <img
			        style="width: 60px;height: 60px;"
			        src="/static/logo.jpg"
			        alt="养老官网"
			      />
			    </el-menu-item>
			    <div class="flex-grow" />
				 <el-menu-item v-for="(item, index) in menuList" :key="index" :index="item.path">
				      {{ item.title }}
				    </el-menu-item>
			  </el-menu>
		</el-affix>
			</match-media>
			<match-media :max-width="768">
				<el-affix :offset="0.1">
				<el-menu
				  :default-active="activeIndex"
				  class="el-menu-demo"
				  mode="horizontal"
				  :ellipsis="false"
				  @select="handleSelect"
				>
				  <el-menu-item index="0">
				    <img
				      style="width: 30px;height: 30px;"
				      src="/static/logo.jpg"
				      alt="养老官网"
				    />
				  </el-menu-item>
				  <div class="flex-grow" />
				<u-icon name="list" size="28" @click="drawer = true;" style="padding-right: 1%;"></u-icon>
			
				 <el-drawer v-model="drawer" :with-header="false" size='40%'>
				    <view v-for="(item, index) in menuList" class="mini-menu-item" :key="index" @click="handleSelect(item.path)">
				    	<view class="mini-menu-title">{{ item.title }}</view>
				    	<u-icon type="forward"></u-icon>
				    </view>
				  </el-drawer>
				</el-menu>
				</el-affix>
			</match-media>
	
	
	</view>
</template>

<script>
	export default {
		name:"b-navigator",
		props: {
			activeIndex:{
				type: String,
				default: '/pages/index/index',
			}
		},
		data() {
			return {
					drawer: false,
					menuList: [
						{ title: '首页',path: '/pages/index/index' },
						{ title: '新闻资讯',path: '/pages/news/index' },
						{ title: '通知公告',path: '/pages/notice/notice' },
						{ title: '养老机构',path: '/pages/organ/index' },
						{ title: '养老地图',path: '/pages/organ/mapView' },
						// { title: '养老视频',path: '/pages/video/index' },
						{ title: '康复器具',path: '/pages/picture/index' },
						{ title: '老年服务',path: '/pages/oldservice/index' },
						{ title: '老年养生',path: '/pages/oldhealth/index' },
						{ title: '关于我们',path: '/pages/about/index' },
					]
			};
		},
		methods: {
			handleSelect(key, keyPath) {
			
				uni.navigateTo({
					url: key
				});
			}
		}
	}
</script>

<style>
.flex-grow {
	  flex-grow: 1;
	}
	.mini-menu-item {
		padding: 20rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		font-size: 28rpx;
	
		&:last-child {
			border: none;
		}
	
		.mini-menu-title {
			font-weight: normal;
		}
	}
</style>